import { IToolTip } from "../../../../../com/mui/manager/IToolTip";
import { TAmuletConfig } from "../../../../../Message/Db/Tables/TAmuletConfig";
import { ItemData } from "../../../resource/info/ItemData";
import { ModelType } from "../../../scene/modle/data/ModelType";
import { Language } from "../../../../../extend/language/Language";
import { ItemsUtil } from "../../shortcuts/item/ItemsUtil";
import { MagicWeaponConfig } from "../../../resource/MagicWeaponConfig";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { ObjCreate } from "../ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { FontUtil } from "../../../../common/font/FontUtil";
import { SWFPlayer } from "../../../scene/modle/SWFPlayer";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
type int = number;
//class MagicWeaponBestShowToolTip
    
    export  class MagicWeaponBestShowToolTip /* flash.display.Sprite */ implements IToolTip
    {
        constructor(arg1: TAmuletConfig=null)
        {
            
            this.initView();
            return;
        }

        public set data(arg1)
        {
            this.init(arg1 as TAmuletConfig);
            return;
        }

        /* internal  */init(arg1: TAmuletConfig): void
        {
            if (arg1 == null) 
            {
                return;
            }
            this._tipData = arg1;
            this._data = new ItemData(arg1.code);
            this._txtName.htmlText = this._data.htmlName;
            this._icon.move(60, 100);
            this._icon.loadComplete = this.loadIconComplete;
            this._icon.load(this._data.effect + ".swf", ModelType.FabaoPlayer, null);
            this._lbGet.htmlText = this._data.itemInfo.item.descStr;
            this._txtScore.htmlText = "<font color=\'#FECD04\'>" + this._tipData.max + "</font>";
            this._txtMaxScore.text = Language.getStringByParam(80361, ItemsUtil.getColorName(this._data.color), int(ItemsUtil.MagicWeaponScoreTimes[this._data.color] * 100).toString());
            this._txtMaxLevel.text = Language.getStringByParam(80345, MagicWeaponConfig.instance.getMaxLvByTypeColor(4, this._data.color));
            this.setProperty();
            return;
        }

        /* internal  */loadIconComplete(arg1): void
        {
            this._icon.move(60, 100);
            return;
        }

        /* internal  */set position(arg1: int)
        {
            this._splitLine.y = 222 + arg1 * 20;
            this._lbGet.y = 227 + arg1 * 20;
            this._txtMaxScore.y = 304 + arg1 * 20;
            this._txtMaxLevel.y = 321 + arg1 * 20;
            this._bg.height = 346 + arg1 * 20;
            return;
        }

        /* internal  */setProperty(): void
        {
            var loc2=null;
            var loc3=null;
            var loc1=this._tipData.strExtend.split(",");
            this._propDes.text = "";
            var loc4=0;
            while (loc4 < loc1.length) 
            {
                loc3 = loc1[loc4] as string;
                loc3 = loc3.replace(new RegExp("\\[", "g"), "");
                loc3 = loc3.replace(new RegExp("\\]", "g"), "");
                loc2 = loc3.split(".");
                if (loc4 != 0) 
                {
                    this._propDes.htmlText = this._propDes.htmlText + (GameDefConfig.instance.getMagicWeaponPropertyName(loc2[0]) + "  " + loc2[1] + "<br>");
                }
                else 
                {
                    this._txtAttack.htmlText = "<font color=\'#FECD04\'>" + GameDefConfig.instance.getMagicWeaponPropertyName(loc2[0]) + "  " + loc2[1] + "</font>";
                }
                ++loc4;
            }
            this.position = loc1.length - 3;
            return;
        }

        /* internal  */initView(): void
        {
            var loc1=null;
            this._bg = ObjCreate.createBg(0, 0, 210, 397, this, ImagesConst.ToolTipBg);
            this._txtName = this.createGTextField("", 0, 10, 200, 20, this);
            loc1 = this._txtName.defaultTextFormat;
            loc1.size = 15;
            loc1.bold = true;
            loc1.align = flash.text.TextFormatAlign.CENTER;
            this._txtName.defaultTextFormat = loc1;
            this._txtScore = this.createGTextField("", 0, 53, 160, 55, this);
            loc1 = this._txtScore.defaultTextFormat;
            loc1.size = 44;
            loc1.font = FontUtil.xingkaiName;
            loc1.align = flash.text.TextFormatAlign.RIGHT;
            this._txtScore.defaultTextFormat = loc1;
            this._score = ObjCreate.createBitmap(ImagesConst.ScoreBig, 160, 56, this);
            this._icon = new SWFPlayer();
            this._icon.move(60, 100);
            this._icon.timeRate = 6;
            this.addChild(this._icon);
            this._lbAttack = this.createGTextField(Language.getString(80339), 8, 106, 78, 20, this);
            this._txtAttack = this.createGTextField("", 33, 127, 150, 20, this);
            this._lbShouHu = this.createGTextField(Language.getString(80340), 8, 155, 78, 20, this);
            var loc2=GlobalStyle.textFormat6;
            loc2.leading = 9;
            this._propDes = ObjCreate.createGTextField("", 30, 175, 290, 270, this, loc2);
            this._propDes.multiline = true;
            this._propDes.wordWrap = true;
            ObjCreate.createBg(18, 100, 166, 2, this, ImagesConst.SplitLine);
            ObjCreate.createBg(18, 149, 166, 2, this, ImagesConst.SplitLine);
            this._splitLine = ObjCreate.createBg(18, 222, 166, 2, this, ImagesConst.SplitLine);
            this._lbGet = ObjCreate.createAutoSizeGTextFiled("", 8, 227, 193, this);
            this._txtMaxScore = this.createGTextField("", 8, 304, 180, 20, this);
            this._txtMaxLevel = this.createGTextField("", 8, 321, 180, 20, this);
            return;
        }

        /* internal  */createGTextField(arg1: string, arg2: int=0, arg3: int=0, arg4: int=220, arg5: int=20, arg6: Object /* flash.display.DisplayObjectContainer */=null, arg7: Object /* flash.text.TextFormat */=null, arg8: Boolean=true): GTextFiled
        {
            var loc1;
            var loc2;
            (loc2 = (loc1 = ObjCreate.createGTextField(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)).defaultTextFormat).size = 13;
            loc1.defaultTextFormat = loc2;
            return loc1;
        }

        /* internal */ /* var */_data: ItemData;

        /* internal */ /* var */_tipData: TAmuletConfig;

        /* internal */ /* var */_txtName: GTextFiled;

        /* internal */ /* var */_icon: SWFPlayer;

        /* internal */ /* var */_score: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_txtScore: GTextFiled;

        /* internal */ /* var */_lbAttack: GTextFiled;

        /* internal */ /* var */_txtAttack: GTextFiled;

        /* internal */ /* var */_lbShouHu: GTextFiled;

        /* internal */ /* var */_lbGet: GTextFiled;

        /* internal */ /* var */_txtMaxScore: GTextFiled;

        /* internal */ /* var */_txtMaxLevel: GTextFiled;

        /* internal */ /* var */_propDes: GTextFiled;

        /* internal */ /* var */_bg: ScaleBitmap;

        /* internal */ /* var */_splitLine: Object /* flash.display.Bitmap */;
    }
